package com.kaibes.admin.user.safe;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.kaibes.web.admin.AdminControllerUtils;
import com.kaibes.web.admin.AdminMenuConfig;
import com.kaibes.web.admin.AdminMenuUtils;

@ControllerAdvice(basePackages = "com.kaibes.module.user.admin")
public class UserSafeControllerAdvice implements InitializingBean {

    @Autowired
    private AdminMenuConfig adminMenuConfig;
    @Autowired
    private AdminControllerUtils controllerUtils;
    
    @ModelAttribute
    public void currentMenu(Model model) {
        controllerUtils.setMenu(model, "/admin/user/safe");
    }

	@Override
	public void afterPropertiesSet() throws Exception {
		AdminMenuUtils.removeByHref(adminMenuConfig.getAdminMenus(), "/admin/user");
	}
    
}
